"""Tests for hanja_dict."""

import hanja_dict

import csv
import unittest
import os

TEST_FILE = 'test.csv'

class HanjaDictTest(unittest.TestCase):
  def setUp(self):
    f = open(TEST_FILE, 'w')
    w = csv.writer(f)
    w.writerow(['hanja1', 'pronan1', 'meaning1', 'stroke1', 'five_element1'])
    w.writerow(['hanja1', 'pronan1', 'meaning1', 'stroke1', 'five_element1'])
    f.close()

    # load
    self._hanja_dict = hanja_dict.HanjaDict(TEST_FILE)

  def tearDown(self):
    os.remove(TEST_FILE)

  def testHanjaDict(self):
    self.assertEquals(
      [
       {'hanja': 'hanja1', 'pronan': 'pronan1', 'meaning': 'meaning1',
        'stroke': 'stroke1', 'five_element': 'five_element1'},
       {'hanja': 'hanja1', 'pronan': 'pronan1', 'meaning': 'meaning1',
        'stroke': 'stroke1', 'five_element': 'five_element1'}
      ], self._hanja_dict.GetHanjaItem('pronan1'))

    self.assertEquals(
      None, self._hanja_dict.GetHanjaItem('pronan2'))


if __name__ == '__main__':
  unittest.main()
